#define  _CRT_SECURE_NO_WARNINGS 1

#include <windows.h>
#include <stdio.h>
#include <time.h>
char* gettime() {
    time_t t;
    struct tm* local_time;
    time(&t);
    local_time = localtime(&t);
    return asctime(local_time);
}
int main() {
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    memset(&si, 0, sizeof(si));
    si.cb = sizeof(si);

    char path[1000] = "D:\code\c++_code\Child_Process\Debug\Child_Process.exe";
    while (true) {
        printf("Those output come from Father_Process, %s\n", gettime());

        if (!CreateProcess(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
            printf("Failed to create child process\n");
            return 1;
        }
        Sleep(2000);
    }
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 0;
}
